{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 一.损失函数\n",
    "\n",
    "这一节对xgboost回归做介绍，xgboost共实现了5种类型的回归，分别是squarederror、logistic、poisson、gamma、tweedie回归，下面主要对前两种进行推导实现，剩余三种放到下一节  \n",
    "\n",
    "#### squarederror\n",
    "即损失函数为平方误差的回归模型：  \n",
    "\n",
    "$$\n",
    "L(y,\\hat{y})=\\frac{1}{2}(y-\\hat{y})^2\n",
    "$$  \n",
    "\n",
    "所以一阶导和二阶导分别为：   \n",
    "\n",
    "$$\n",
    "\\frac{\\partial L(y,\\hat{y})}{\\partial \\hat{y}}=\\hat{y}-y\\\\\n",
    "\\frac{\\partial^2 L(y,\\hat{y})}{{\\partial \\hat{y}}^2}=1.0\\\\\n",
    "$$  "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### logistic\n",
    "\n",
    "由于是回归任务，所以y也要套上`sigmoid`函数（用$\\sigma(\\cdot)$表示），损失函数：   \n",
    "\n",
    "$$\n",
    "L(y,\\hat{y})=(1-\\sigma(y))log(1-\\sigma(\\hat{y}))+\\sigma(y)log(\\sigma(\\hat{y}))\n",
    "$$\n",
    "\n",
    "一阶导和二阶导分别为：   \n",
    "\n",
    "$$\n",
    "\\frac{\\partial L(y,\\hat{y})}{\\partial \\hat{y}}=\\sigma(\\hat{y})-\\sigma(y)\\\\\n",
    "\\frac{\\partial^2 L(y,\\hat{y})}{{\\partial \\hat{y}}^2}=\\sigma(\\hat{y})(1-\\sigma(\\hat{y}))\\\\\n",
    "$$   \n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 二.代码实现\n",
    "具体流程与gbdt的回归类似，只是每次要计算一阶、二阶导数信息，同时基学习器要替换为上一节的xgboost回归树"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "os.chdir('../')\n",
    "import matplotlib.pyplot as plt\n",
    "%matplotlib inline\n",
    "from ml_models.ensemble import XGBoostBaseTree\n",
    "from ml_models import utils\n",
    "import copy\n",
    "import numpy as np\n",
    "\n",
    "\"\"\"\n",
    "xgboost回归树的实现，封装到ml_models.ensemble\n",
    "\"\"\"\n",
    "\n",
    "class XGBoostRegressor(object):\n",
    "    def __init__(self, base_estimator=None, n_estimators=10, learning_rate=1.0, loss='squarederror'):\n",
    "        \"\"\"\n",
    "        :param base_estimator: 基学习器\n",
    "        :param n_estimators: 基学习器迭代数量\n",
    "        :param learning_rate: 学习率，降低后续基学习器的权重，避免过拟合\n",
    "        :param loss:损失函数，支持squarederror、logistic\n",
    "        \"\"\"\n",
    "        self.base_estimator = base_estimator\n",
    "        self.n_estimators = n_estimators\n",
    "        self.learning_rate = learning_rate\n",
    "        if self.base_estimator is None:\n",
    "            # 默认使用决策树桩\n",
    "            self.base_estimator = XGBoostBaseTree()\n",
    "        # 同质分类器\n",
    "        if type(base_estimator) != list:\n",
    "            estimator = self.base_estimator\n",
    "            self.base_estimator = [copy.deepcopy(estimator) for _ in range(0, self.n_estimators)]\n",
    "        # 异质分类器\n",
    "        else:\n",
    "            self.n_estimators = len(self.base_estimator)\n",
    "        self.loss = loss\n",
    "\n",
    "    def _get_gradient_hess(self, y, y_pred):\n",
    "        \"\"\"\n",
    "        获取一阶、二阶导数信息\n",
    "        :param y:真实值\n",
    "        :param y_pred:预测值\n",
    "        :return:\n",
    "        \"\"\"\n",
    "        if self.loss == 'squarederror':\n",
    "            return y_pred - y, np.ones_like(y)\n",
    "        elif self.loss == 'logistic':\n",
    "            return utils.sigmoid(y_pred) - utils.sigmoid(y), utils.sigmoid(y_pred) * (1 - utils.sigmoid(y_pred))\n",
    "\n",
    "    def fit(self, x, y):\n",
    "        y_pred = np.zeros_like(y)\n",
    "        g, h = self._get_gradient_hess(y, y_pred)\n",
    "        for index in range(0, self.n_estimators):\n",
    "            self.base_estimator[index].fit(x, g, h)\n",
    "            y_pred += self.base_estimator[index].predict(x) * self.learning_rate\n",
    "            g, h = self._get_gradient_hess(y, y_pred)\n",
    "\n",
    "    def predict(self, x):\n",
    "        rst_np = np.sum(\n",
    "            [self.base_estimator[0].predict(x)] +\n",
    "            [self.learning_rate * self.base_estimator[i].predict(x) for i in\n",
    "             range(1, self.n_estimators - 1)] +\n",
    "            [self.base_estimator[self.n_estimators - 1].predict(x)]\n",
    "            , axis=0)\n",
    "        return rst_np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "#测试\n",
    "data = np.linspace(1, 10, num=100)\n",
    "target = np.sin(data) + np.random.random(size=100)  # 添加噪声\n",
    "data = data.reshape((-1, 1))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAX8AAAD8CAYAAACfF6SlAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAIABJREFUeJzt3XuQXHWd9/H3dy7JTK6dhADJhJCoERS5BEchCYgVYWWVByKugj7rorUWVU/pLuLlMezqQllbRba0vOwuK8sqCisPIoqQ54EVkahguMiQxI2AXBVmOoGEwCSTZJLM5ff80d1JT8853af7nO7Tfc7nVTXVM90nfQ7N6e/5nu/vZs45REQkXdriPgAREWk8BX8RkRRS8BcRSSEFfxGRFFLwFxFJIQV/EZEUUvAXEUkhBX8RkRRS8BcRSaGOuA/Az1FHHeWWLFkS92GIiLSUxx9//FXn3PxK2zVt8F+yZAl9fX1xH4aISEsxsxeDbKeyj4hICin4i4ikUOjgb2bHmdkvzewpM3vCzK7w2MbM7J/N7Dkz+28zOz3sfkVEpHZR1PxHgc855zaZ2UzgcTO7zzn3ZNE2fw4sy/+cAXw7/ygiIjEInfk757Y75zblfx8C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WZP5Re4vyLuY2oGZtZuZpvN7P/FfSxxMrOMmf3YzP6QP0dWxH1McTKzK/Pfk9+b2a1m1hX3MTWSmd1oZjvM7PdFz801s/vM7Nn845yo96vgXx+jwOecc28BzgQ+ZWZvjfmYmsEVwFNxH0QT+BbwM+fcicCppPgzMbMe4G+BXufc28hN+35pvEfVcN8Hzi95bi1wv3NuGXB//u9IKfjXgXNuu3NuU/73IXJf7lRPPG9mi4D3A9+J+1jiZGazgHcB3wVwzh1yzg3Ge1Sx6wC6zawDmIbPSn9J5Zx7AHit5OmLgJvyv98ErIl6vwr+dWZmS4DlwKPxHknsvgn8b2A87gOJ2RuAncD38iWw75jZ9LgPKi7OuSzwNeAlYDuw2zn383iPqikc45zbDrlkEjg66h0o+NeRmc0AfgJ8xjm3J+7jiYuZXQDscM49HvexNIEO4HTg28655cA+6nBL3yryteyLgKXAQmC6mf1lvEeVDgr+dWJmneQC/y3OuTviPp6YrQIuNLM/AT8EVpvZD+I9pNgMAAPOucKd4I/JXQzS6lzgj865nc65EeAOYGXMx9QMXjGzBQD5xx1R70DBvw7MzMjVdJ9yzn097uOJm3PuKufcIufcEnKNeRucc6nM7pxzLwP9ZnZC/qn3AE/GeEhxewk408ym5b837yHFDeBF1gOX5X+/DLgr6h2EWsNXfK0CPgZsNbMt+ef+Lr+WscjfALeY2RTgBeATMR9PbJxzj5rZj4FN5HrJbSZlo33N7Fbg3cBRZjYAXA2sA35kZn9N7gL5ocj3qxG+IiLpo7KPiEgKKfiLiKSQgr+ISAop+IuIpJCCv4hICin4i4ikkIK/iEgKKfiLiKTQ/wcQG9mvHLGnVgAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x20350e52cc0>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "model = XGBoostRegressor(loss='squarederror')\n",
    "model.fit(data, target)\n",
    "plt.scatter(data, target)\n",
    "plt.plot(data, model.predict(data), color='r')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAX8AAAD8CAYAAACfF6SlAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAIABJREFUeJzt3X+UXGWd5/H3N92dpBOSdDrdQNJJCGBgVILE9ACSATHAouCBLOgBXR30zGzcPbIK4+oGnR3dOZ4lc9hRnJEDRkRhREAFIUp2WSV6wLggnR8CIZKEAOnuBAj5/aNJJ51n/6iqpLr63qq6dW/Vrbr38zonp7qrbte9FLe+97nf5/s8jznnEBGRdBkV9wGIiEjtKfiLiKSQgr+ISAop+IuIpJCCv4hICin4i4ikkIK/iEgKKfiLiKSQgr+ISAo1x30Afjo6OtysWbPiPgwRkYayatWqt51znaW2q9vgP2vWLHp6euI+DBGRhmJmr5ezndI+IiIppOAvIpJCoYO/mc0ws9+a2XozW2dmX/TYxszsX8xsk5k9b2bvD7tfERGpXBQ5/yPAl5xzq81sArDKzH7tnHspb5uPALOz/84D7sw+iohIDEK3/J1z25xzq7M/7wPWA10Fm10N3OcyngHazGxq2H2LiEhlIs35m9ksYC7wbMFLXUBv3u99jLxAiIhIjURW6mlmJwAPAzc55/YWvuzxJyOWEDOzRcAigJkzZ0Z1aCM8uqaf2554ma27B5jW1sqXLz+ThXN1LRKR9Iik5W9mLWQC//3OuUc8NukDZuT9Ph3YWriRc26pc67bOdfd2VlyjEJFHl3Tzy2PvED/7gEc0L97gFseeYFH1/RXZX8iIvUoimofA34ArHfOfctns2XAX2erfs4H9jjntoXddyVue+JlBg4PDXtu4PAQtz3xchyHIyISiyjSPvOBTwMvmNna7HNfBWYCOOfuApYDVwCbgIPAZyPYb0W27h4I9LyISBKFDv7Oud/jndPP38YBnw+7ryhMa2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nZa8CDwAIz+3G8hxSbPqDPOZe7E/w5mYtBWl0KvOqc2+6cOww8AlwQ8zHVgzfNbCpA9vGtqHeg4F8FZmZkcrrrnXPfivt44uacu8U5N905N4tMZ94K51wqW3fOuTeAXjM7M/vUJcBLMR5S3LYA55vZuOz35hJS3AGeZxlwQ/bnG4DHot5BqDV8xdd84NPAC2a2NvvcV7NrGYv8F+B+MxsNbAY+G/PxxMY596yZ/RxYTaZKbg0pG+1rZg8AFwMdZtYHfB1YAvzUzP6GzAXy45HvVyN8RUTSR2kfEZEUUvAXEUkhBX8RkRRS8BcRSSEFfxGRFFLwFxFJIQV/EZEUUvAXEUmh/w9S3+vzkmk54gAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x20350e52da0>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "model = XGBoostRegressor(loss='logistic')\n",
    "model.fit(data, target)\n",
    "plt.scatter(data, target)\n",
    "plt.plot(data, model.predict(data), color='r')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
